*Set up
clear all
set memory 5g

set more off

use "\\ead02\ead_uquam\Localization\NAICS6_panel\restat_final.dta", clear

cd "\\ead02\ead_uquam\Localization\restat_results"


*TSET FUNCTION;

destring naics, replace
destring oecd80, replace

xtset naics year, delta(1)




//Baseline panel etimates for model (1)

*CDF evaluated at 50km: Fixed effects

xi: xtreg  ln_cdf50 lnav_klems i.year, fe cluster(naics)
estimates store Model_1_CDF50km
outreg2 using CDF50FE, ctitle("FE1: CDF 50km")  sideway alpha (0.01,0.05,0.10) symbol(a,b,c) stats(coef aster se) noparen excel e(all) replace

xi: xtreg  ln_cdf50 lnav_klems m_asiashr m_oecdshr m_naftashr x_asiashr x_oecdshr x_naftashr i.year, fe cluster(naics)
estimates store Model_2_CDF50km
outreg2 using CDF50FE, ctitle("FE2: CDF 50km")  sideway alpha (0.01,0.05,0.10) symbol(a,b,c) stats(coef aster se) noparen excel e(all) append

xi: xtreg  ln_cdf50 lnav_klems lnl_idist_n5 lnl_odist_n5 lndistn5 i.year, fe cluster(naics)
estimates store Model_3_CDF50km
outreg2 using CDF50FE, ctitle("FE3: CDF 50km")  sideway alpha (0.01,0.05,0.10) symbol(a,b,c) stats(coef aster se) noparen excel e(all) append

xi: xtreg  ln_cdf50 lnav_klems m_asiashr m_oecdshr m_naftashr x_asiashr x_oecdshr x_naftashr lnl_idist_n5 lnl_odist_n5 lndistn5 i.year, fe cluster(naics)
estimates store Model_4_CDF50km
outreg2 using CDF50FE, ctitle("FE4: CDF 50km")  sideway alpha (0.01,0.05,0.10) symbol(a,b,c) stats(coef aster se) noparen excel e(all) append

xi: xtreg  ln_cdf50 lnav_klems ln_empl lnherfent lnm_emp nmulti1 nfown lnnrs lnpee lnifqh3shr lnrdl i.year, fe cluster(naics)
estimates store Model_5_CDF50km
outreg2 using CDF50FE, ctitle("FE5: CDF 50km")  sideway alpha (0.01,0.05,0.10) symbol(a,b,c) stats(coef aster se) noparen excel e(all) append

xi: xtreg  ln_cdf50 lnav_klems ln_empl lnherfent lnm_emp nmulti1 nfown lnnrs lnpee lnifqh3shr lnrdl m_asiashr m_oecdshr m_naftashr x_asiashr x_oecdshr x_naftashr lnl_idist_n5 lnl_odist_n5 lndistn5 i.year, fe cluster(naics)
estimates store Model_6_CDF50km
outreg2 using CDF50FE, ctitle("FE6: CDF 50km")  sideway alpha (0.01,0.05,0.10) symbol(a,b,c) stats(coef aster se) noparen excel e(all) append

xi: xtreg  ln_cdf50 lnav_klems_resid ln_empl lnherfent lnm_emp nmulti1 nfown lnnrs lnpee lnifqh3shr lnrdl m_asiashr m_oecdshr m_naftashr x_asiashr x_oecdshr x_naftashr lnl_idist_n5 lnl_odist_n5 lndistn5 i.year, fe cluster(naics)
estimates store Model_7_CDF50km
outreg2 using CDF50FE, ctitle("FE7: CDF 50km")  sideway alpha (0.01,0.05,0.10) symbol(a,b,c) stats(coef aster se) noparen excel e(all) append

/*
gen lnempasm=log(salemp+prdwrk)

xi: xtreg lnempasm lnav_klems_resid i.year, fe cluster(naics)
*/
